home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / utility / horst_2.zip / NSET.DOC < prev    next >
Text File  |  1995-12-18  |  3KB  |  86 lines

  1. ------------------------------------------------------------------------
  2. NSET    Variables from STDIN            Ver 1.2 (c) 1994 Horst Schaeffer
  3. ------------------------------------------------------------------------
  4.  
  5. NSET sets an environment variable using data from STDIN. It was
  6. especially designed to extract data from DOS command output of DIR,
  7. DATE, TIME, VOL, FIND etc.
  8.  
  9. Syntax using different ways of STDIN:
  10.  
  11.     command | NSET [options] varname=string             (pipe)
  12.  
  13.     NSET [options] varname=string < file                (from a file)
  14.  
  15.     NSET [options] varname=string                       (keyboard)
  16.  
  17. The string may include tokens $1...$99 referring to the n-th word of
  18. STDIN (several variables in any order allowed).
  19.  
  20. Example:
  21.  
  22.     CD | NSET SDIR=$1                   (keep SDIR=current directory)
  23.     VOL A: | NSET LABEL=$6              (set LABEL=volume label of A:)
  24.  
  25. NSET allows mixing of extracted words with constant or variable strings:
  26.  
  27.     NSET X=\UTIL\$1.$2
  28.     NSET Y=%TEMP%\$1
  29.  
  30. Separators between input words are: blanks, comma, semicolon, equal sign
  31. and carriage return / line feed.
  32. If the input has several lines, just count the words across lines.
  33.  
  34. Options:
  35.  
  36. /S  additional separators (one or more, up to space)
  37.     As an example, you can split up the current date to translate
  38.     UK to US format:
  39.  
  40.     echo.|date|nset /S/ USdate=$6-$5-$7
  41.  
  42.     date output was:  Current Date is  Fri, 16/09/1994
  43.     tokens available:   $1     $2  $3  $4   $5 $6  $7
  44.  
  45. /U  input words converted to upper case
  46.  
  47. /L  extract from specified line only ($1 will refer to 1st word in
  48.     this line). To get the path of a given file only the 4th line
  49.     of the DIR output is used:
  50.  
  51.     DIR %fn% | NSET /L4 FPATH=$3
  52.                     ---
  53.  
  54. Notes:
  55.  
  56. If you omit the variable name, the result will be sent to STDOUT.
  57. Useful for testing or to redirect to a file. (The equal sign must not be
  58. omitted!)
  59.  
  60. If there is nothing succeeding the equal sign, $1 is assumed.
  61.  
  62. Trailing blanks are removed from the string.
  63.  
  64. Errorlevel: 0: ok, 1: out of environment space
  65.  
  66. To avoid conflicts when numeric data occur in the string, you may use
  67. e.g. $01 instead of $1 (because only 2 digits are read for tokens):
  68.  
  69.         $15         is the 15th word
  70.         $015        is the 1st word succeeded by constant "5"
  71.  
  72.  
  73. More Examples:
  74.  
  75.     NSET INPUT=$1 $2 $3                 (max 3 words from keyboard)
  76.  
  77.     dir %file% /B | NSET /S. EXT=$1     (file name without extension)
  78.     dir %file% /B | NSET /S. EXT=$2     (file extension only)
  79.  
  80.     vol | NSET DRV=$4:                  (current drive)
  81.  
  82.     truename %1 | NSET /S\ DRV=$1       (drive of filespec %1)
  83.  
  84.  
  85. = 25 FEB 1995
  86.